package com.buptse.utils;

import com.buptse.model.Information;

public class DirectoryDecoder {
    enum DirectoryCategory{
        _101("101","震情信息"),
        _201("201","死亡"),
        _202("202","受伤"),
        _203("203","失踪"),
        _301("301","土木"),
        _302("302","砖木"),
        _303("303","砖混"),
        _304("304","框架"),
        _305("305","其他"),
        _401("401","交通"),
        _402("402","供水"),
        _403("403","输油"),
        _404("404","燃气"),
        _405("405","电力"),
        _406("406","通信"),
        _407("407","水利"),
        _501("501","崩塌"),
        _502("502","滑坡"),
        _503("503","泥石流"),
        _504("504","岩溶塌陷"),
        _505("505","地裂缝"),
        _506("506","地面沉降"),
        _507("507","其他(沙土液化、火灾、毒气泄漏、爆炸、环境污染、瘟疫、海啸等)");

        private String code;
        private String description;

        // 枚举的构造函数，可以带不同的参数
        DirectoryCategory(String code, String description) {
            this.code = code;
            this.description=description;
        }

        public String getCode() {
            return code;
        }


        public String getDescription() {
            return description;
        }

        public static String getInfoByCode(String code) {
            for (DirectoryCategory directoryCategory : values()) {
                if (directoryCategory.getCode().equals(code)) {
                    return directoryCategory.getDescription();
                }
            }
            return "Code not found";
        }
    }

    public static void directoryDecode(String code, Information information){
        String directoryInformation= DirectoryCategory.getInfoByCode(code);
        information.setDirectory(directoryInformation);
    }
}
